package com.ubing.boot.notesforjava.test.rocketMQ;

import com.alibaba.fastjson2.JSON;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.ubing.boot.notesforjava.domel.entity.NoteInfo;
import com.ubing.boot.notesforjava.domel.entity.UserInfo;
import com.ubing.boot.notesforjava.domel.entity.UserTest;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.hibernate.validator.internal.util.logging.Log;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

@NoArgsConstructor
@Data
public class SyncProducer {

    public static void main(String[] args) throws Exception {
        // 初始化一个producer并设置Producer group name
        DefaultMQProducer producer = new DefaultMQProducer("please_rename_unique_group_name"); //（1）
        // 设置NameServer地址
        producer.setNamesrvAddr("120.46.147.78:9876");  //（2）
        // 启动producer
        producer.start();
        Message msg = new Message("TopicTest" /* Topic */,
                "TagA" /* Tag */,
                "唐子淋，大傻逼".getBytes() /* Message body */
        );   //（3）
        SendResult send = producer.send(msg,200000);
        System.out.println(send);
        // 一旦producer不再使用，关闭producer
        producer.shutdown();
    }
}